<template>
  <div>
     <!-- <headerNave :nva-datas="navDatas" v-on:backNav="backNav"></headerNave> -->
     <components :is="currentView" v-on:changeView="changeView" v-on:backPrev="backPrev" :template-obj="templateObj"></components>
  </div>
</template>
<script>
  import $ from 'jquery'
  import headerNave from '../../../../components/headerNave'
  import {GloabFun,Animation,HttpServer} from '../../../../assets/js/common.js'
   //图书列表
   const List = resolve => require(['./List.vue'], resolve)
   //图书豆瓣信息
   const DouBanInfo = resolve => require(['./DouBanInfo.vue'], resolve)

  export default {
    components: {
      List,
      DouBanInfo,
      headerNave
    },
    data() {
      return {
        currentView:"List",
        templateObj:{
          DistrictId:this.subArgs.DistrictId,
          CurrentView:this.subArgs.CurrentView
        },
        navDatas:[{
            name:this.subArgs.CurrentView,
            view:"List"
        }]
      };
    },
    props:{
        subArgs:{
            type: Object,
            default:{}
        }
    },
    methods: {
      changeView(view,obj){
        GloabFun.clearRecordPreview.call(this);
        obj.DistrictId=this.subArgs.DistrictId;
        obj.CurrentView=this.subArgs.CurrentView;
        Animation.animation($("#mainContent"),function(){
          if(obj){
            this.navDatas=[{
              name:this.subArgs.CurrentView,
              view:"List"
            }];
            this.templateObj=obj;
            if(view==="DouBanInfo"){
               this.navDatas.push({
                  name:"图书详情->" +obj.name,
                  view:"DouBanInfo"
               });
            }
          }
          this.currentView=view;
        }.bind(this));
      },
      backPrev(){
          this.$emit('backPrev');
      },
      backNav(item){
        if(item.view==="List"){
           // this.changeView("List",{});
           this.changeView("List",this.templateObj);
        }
      }
    }
  }
</script>